{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# 变量和对象"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "对象并没有直接存储到变量中，在 Python 中更像是给对象起了一个别名\n",
    "\n",
    "| 变量 | 值    |\n",
    "| ---- | ----- |\n",
    "| a    | id |\n",
    "\n",
    "- 变量中储存的不是对象的值，而是对象的 id\n",
    "- 变量中保存的 id，只有在为变量重新赋值时才会改变\n",
    "- 变量和变量之间是相互独立的，修改一个变量 id 不会影响另一个变量"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 10\n",
    "print(f\"a = {a}, id = {id(a)}\")\n",
    "b = a\n",
    "print(f\"b = {b}, id = {id(b)}\")\n",
    "a = 20\n",
    "print(f\"a = {a}, id = {id(a)}\")\n",
    "print(f\"b = {b}, id = {id(b)}\")"
   ]
  }
 ]
}